package xhwl.insurance.http.api;

import com.google.gson.Gson;

import okhttp3.RequestBody;
import rx.Observable;
import xhwl.android.common.util.SPUtil;
import xhwl.insurance.Constant;
import xhwl.insurance.http.ApiService;
import xhwl.retrofitrx.BaseApi;

/**
 * Created by admin on 2017/6/7.
 * 阅片订单提交
 */

public class XDYPOrderSubmitApi extends BaseApi {
    XDYPOrderReq req;

    public XDYPOrderSubmitApi(String hos_name, String buy_type, String pay_money) {
        req = new XDYPOrderReq(hos_name, buy_type, pay_money);
    }

    @Override
    protected Observable getObservable() {
        RequestBody requestBody = RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"), new Gson().toJson(req));
        return retrofit.create(ApiService.class).submitOrderyuepian(requestBody);
    }

    class XDYPOrderReq {

        /**
         * link_mobile : 5
         * yw_id : 2
         * hos_name : 丁庄镇三岔村
         * buy_type : 0
         * pay_money : 180
         */

        private String link_mobile;
        private String yw_id;
        private String hos_name;
        private String buy_type;
        private String pay_money;

        public XDYPOrderReq(String hos_name, String buy_type, String pay_money) {
            this.link_mobile = SPUtil.getPersonInfoSp().getString(SPUtil.SPPersonInfo.LINK_MOBILE, "");
            this.yw_id = Constant.YW_ID;
            this.hos_name = hos_name;
            this.buy_type = buy_type;
            this.pay_money = pay_money;
        }
    }
}
